{% extends "base.html" %}

{% block title %}Log a He transfer{% endblock %}

{% block head %}
{{ super() }}
<script type="text/javascript" src="{{ url_for('static', filename='jquery-1.4.4.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='he_calc.js') }}"></script>

{% endblock %}

{% block body %}

{% with messages = get_flashed_messages(with_categories=True) %}
  {% if messages %}
    <ul class="flashes">
    {% for category, message in messages %}
      <li class="{{ category }}">{{ message }}</li>
    {% endfor %}
    </ul>
  {% endif %}
{% endwith %}

<h1>Log a He transfer</h1>
    
{% from "_formhelpers.html" import render_field %}
<form id="log_transfer" method="post" action="{{ url_for('index') }}">
    <table class="layout">
        <tr>
            <td>{{ form.user.label }}</td>
            <td colspan="2">{{ form.user|safe }}
                {% if form.user.errors %}
                <ul>
                    {% for error in form.user.errors %}<li>{{ error }}</li>{% endfor %}
                </ul>
                {% endif %}</td>
            <td colspan="3"><em><small>Meter values should include a decimal point</small></em></td>
        </tr>
        <tr>
            {{ render_field(form.meter, 0) }}
            {{ render_field(form.meter_before, 0) }}
            {{ render_field(form.meter_after, 0) }}
        </tr>
        <tr>
            {{ render_field(form.transport_dewar, 0) }}
            {{ render_field(form.transport_dewar_before, 0) }}
            {{ render_field(form.transport_dewar_after, 0) }}
        </tr>
        <tr>
            {{ render_field(form.cryostat, 5)}}
        </tr>
<!--
        <tr>
            <td colspan="6" align="right">
                <input type="submit" value="Log a transfer">
            </td>
        </tr>
-->
        <tr>
            <td>Litres taken</td>
            <td colspan="5" class="big_num" id="he_taken">N/A<td>
        </tr>
        <tr>
            <td>Litres boiled off</td>
            <td colspan="5" class="big_num" id="he_boiled_off">N/A</td>
        </tr>
        <tr>
            <td>Approx. extra in cryostat</td>
            <td colspan="5" class="big_num" id="he_in_cryostat">N/A</td>
        </tr>    
    </table>
    If this seems sensible, then <input type="submit" value="log the transfer">
</form>

<h2>Last 10 transfers ...</h2>

<table class="transfers" border="1">
{% if transfers %}
    <tr>
        <th rowspan="2">Transferred by</th>   
        <th colspan="3">Meter</th>
        <th colspan="3">Transport dewar</th>
        <th rowspan="2">Cryostat</th>
        <th rowspan="2">Time</th>
    </tr>
    <tr>
        <th>Name</th>
        <th>Before</th>
        <th>After</th>
        <th>Name</th>
        <th>Before</th>
        <th>After</th>
    </tr>
{% for transfer in transfers %}
    <tr>
        <td>{{ transfer['user'] }}</td>
        <td>{{ transfer['meter'] }}</td>
        <td>{{ transfer['meter_before'] }}</td>
        <td>{{ transfer['meter_after'] }}</td>
        <td>{{ transfer['transport_dewar'] }}</td>
        <td>{{ transfer['transport_dewar_before'] }}</td>
        <td>{{ transfer['transport_dewar_after'] }}</td>
        <td>{{ transfer['cryostat'] }}</td>
        <td>{{ transfer['time'] }}</td>
    </tr>
{% endfor %}
{% else %}
    <tr>
        <td>No transfers logged yet ...</td>
    </tr>    
{% endif %}
</table>


   
{% endblock %}
